package com.liangzhong.model.activity
{
	import flash.events.Event;
	import flash.events.EventDispatcher;

	/**
	 *冲级活动 
	 * @author lake
	 * 
	 */	
	public class ActivityGradeVo extends EventDispatcher
	{
		/**
		 *参加活动的等级 
		 */		
		public var initGrade :int ;
		/**
		 *当前级别
		 * 1 2 3 4 5 6 
		 *  如31级 为3级别
		 */		
		public var curLv		:int;
		/**
		 *冲级级别 
		 */		
		public var levels :Array = [20,30,35,40,45,50];
		/**
		 *领取状态
		 * 0 不可领取
		 * 1 可以领取 
		 */		
		public var getStatas :Array = [0,0,0,0,0,0];
		/**
		 *获取奖励的index 
		 */		
		public var getAwardIndex :int;
		
		public function ActivityGradeVo()
		{
		}
		/**
		 *获取级别帧 
		 * @param lv
		 * @return 
		 * 
		 */		
		public function getLvFrame(lv :int):int
		{
			for(var i :int = 0;i < levels.length;i++)
			{
				if(levels[i]>lv)
				{
					return (i +1);
				}
			}
			return 1;
		}
		/**
		 *解析数据 
		 * @param obj
		 * 
		 */		
		public function parse(obj :Object):void
		{
			initGrade = obj.list.init;
			curLv = obj.list.current;
			getAwardIndex = curLv;
			var itemObj :Object;
			var i :int = 0;
			for(i = 0;i < 6;i ++)
			{
				itemObj = obj.list["" + (i+1)];
				if(itemObj.is_get == 1)//可领取
				{
					getStatas[i] = 1;
				}
				if(itemObj.has_get == 1)//已经领取
				{
					getStatas[i] = 2;
				}
				if(getAwardIndex == (i+1) && getStatas[i] == 2)
				{
					getAwardIndex ++;
				}
			}
			//测试
			//initGrade = 31;
			//getAwardIndex = 3;
			//getStatas = [2,2,1,1,1,1];
			this.dispatchEvent(new Event(Event.CHANGE));
		}
	}
}